//
//  InvestSuccessViewController.m
//  Kjs-iOS
//
//  Created by 江伟 on 16/8/20.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "InvestSuccessViewController.h"
#import "UIColor+KjsColor.h"
#import "InvestManageViewController.h"

@interface InvestSuccessViewController ()
@property (nonatomic,weak) IBOutlet UITextView *tipsTView;
@property (nonatomic,weak) IBOutlet UILabel *investMoneyLab;

@property (nonatomic,weak) IBOutlet NSLayoutConstraint *topDis;
@end

@implementation InvestSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setTitle:@"支付成功"];
    self.topDis.constant = self.navigationController.navigationBar.frame.size.height + 20;
    self.tipsTView.editable = NO;
    //创建 NSMutableAttributedString
    NSMutableAttributedString *tipsStr = [[NSMutableAttributedString alloc] initWithString: self.tipsTView.text];
    //调整行间距
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:10];
    [tipsStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.tipsTView.text length])];
    //分段控制，最开始4个字符颜色设置成蓝色
    [tipsStr addAttribute: NSForegroundColorAttributeName value: [UIColor colorWithRed:102/255.0f green:102/255.0f blue:102/255.0f alpha:1] range: NSMakeRange(0,[tipsStr length])];
    [tipsStr addAttribute: NSForegroundColorAttributeName value: [UIColor kjsMainColor] range: NSMakeRange(31,16)];
    [tipsStr addAttribute: NSForegroundColorAttributeName value: [UIColor kjsMainColor] range: NSMakeRange(49,7)];
    self.tipsTView.attributedText = tipsStr;
    
    self.investMoneyLab.text = [NSString stringWithFormat:@"¥%.2lf元",self.investMoney];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showInvestManage)];
    self.tipsTView.userInteractionEnabled = YES;
    [self.tipsTView addGestureRecognizer:tap];
}

-(void)showInvestManage
{
    InvestManageViewController *investManageVC = [[UIStoryboard storyboardWithName:@"Seconed" bundle:nil] instantiateViewControllerWithIdentifier:@"InvestManageViewController"];
    investManageVC.callViewType = @"investSuccess";
    [self displayViewController:investManageVC];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
